package com.example.calculatorApp.common;

import lombok.Data;

@Data
public class Result  {
//    成功碼
    private static final String SUCCESS_CODE="200";
//    失敗碼
    private static  final String ERROR_CODE="-1";

    private String code;
    private String msg;
    private Object data;

    public static Result success(Object data){
        Result result = new Result();
        result.setCode(SUCCESS_CODE);
        result.setData(data);
        return  result;
    }

    public static Result success(){
        Result result = new Result();
        result.setCode(SUCCESS_CODE);
        return  result;
    }

    public static Result error(String msg) {
        Result result = new Result();
        result.setCode(ERROR_CODE);
        result.setData(null);
        result.setMsg(msg);
        return result;
    }


    public static Result error(String code, String message) {
        Result result = new Result();
        result.setCode(code);
        result.setData(null);
        result.setMsg(message);
        return result;
    }



}
